<template>
<div style="padding-bottom:20px">
  <Form ref="formFooter" :model="formFooter">
    <table
      class="m-table"
      border="1"
      cellpadding="0"
      cellspacing="0"
      style="width:1100px;border:none; text-align:center;margin:0 auto "
    >
      <tr class="content-text">
        <td colspan="2">工程质量等级评定:</td>
        <td colspan="4">
          <Form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="80">
           <FormItem  prop="result">
              <RadioGroup @on-change="changeResult" size="large" v-model="formValidate.result">
                <Radio label="1">合格</Radio>
                <Radio label="0">不合格</Radio>
              </RadioGroup>
           </FormItem>
          </Form>
        </td>
        <td colspan="1">日期:</td>
        <td colspan="5">
          <DatePicker
            size="small"
            type="date"
            @on-change="selectTime"
            placeholder="根据流程默认生成"
            v-model="formFooter.riqi"
          ></DatePicker>
        </td>
      </tr>
      <!-- <tr class="content-text">
        <td>检测负责人:</td>
        <td>
          <FormItem prop="jiance_fuzeren">
            <Input
              type="text"
              disabled
              v-model="formFooter.jiance_fuzeren"
              placeholder="根据流程默认生成"
            ></Input>
          </FormItem>
        </td>
        <td>检测:</td>
        <td>
          <FormItem prop="jiance">
            <Input
              type="text"
              disabled
              v-model="formFooter.jiance"
              placeholder="根据流程默认生成"
            ></Input>
          </FormItem>
        </td>
        <td>记录:</td>
        <td>
          <FormItem prop="jilu">
            <Input
              type="text"
              disabled
              v-model="formFooter.jilu"
              placeholder="根据流程默认生成"
            ></Input>
          </FormItem>
        </td>
        <td>复核:</td>
        <td>
          <FormItem prop="fuhe">
            <Input
              disabled
              type="text"
              v-model="formFooter.fuhe"
              placeholder="根据流程默认生成"
            ></Input>
          </FormItem>
        </td>
        <td>日期:</td>
        <td>
          <DatePicker
            size="small"
              disabled
            type="date"
            @on-change="selectTime"
            placeholder="根据流程默认生成"
            v-model="formFooter.riqi"
          ></DatePicker>
        </td>
      </tr> -->
    </table>
  </Form>
  </div>
</template>

<script>
import apiObj from '@/api/manage-construction.js';

export default {
  name: 'table-footer-pd',
  props: {
    formFooter: {
      type: Object,
      required: true
    },
    nodeId: {
      type: Number,
      required: true
    },
    reportId: {
      type: Number,
      required: true
    }
  },
  data () {
    return {
      editing: false,
      formValidate: {
        result: this.formFooter.gongcheng_zhiliang_dengji_pingding
      },
      ruleValidate: {
        result: [
          { required: true, message: ' ', trigger: 'change' }
        ]
      }

      //   formFooter: {}
    };
  },
  watch: {
    formFooter (newV, oldV) {
      this.formValidate.result = newV.gongcheng_zhiliang_dengji_pingding;
    },
    deep: true
  },
  methods: {
    //
    changeResult (value) {
      console.log(typeof value);
      this.$emit('changeResult', value);
    },
    async saveFooter (name) {
      this.$refs[name].validate(async (valid) => {
        if (valid) {
          for (let protoPer in this.formFooter) {
            this.formFooter[protoPer] = this.formFooter[protoPer] == null ? '' : this.formFooter[protoPer];
          }
          const send = this.formFooter;
          await apiObj.savePDTablefooter(send);
          this.$Message.success('保存成功');
          this.$emit('on-success');
        } else {
          this.$Message.error('请选择评定结果!');
        }
      });
    },
    selectTime (e) {
      console.log('e', e);
      this.formFooter.nowDate = e;
      console.log('formFooter.nowDate', this.formFooter.nowDate);
      this.formFooter.riqi = e;
    }
  },

  mounted () {
    this.formFooter.nowDate = new Date(this.formFooter.riqi);
    console.log('this.formFooter', this.formFooter);
  }
};
</script>
<style lang="less" scoped>
/deep/ .ivu-input {
  border: none !important;
}
/deep/ .ivu-input:focus {
  outline: none;
  border: none;
  box-shadow: 0 0 0 1px transparent;
}
.ivu-form-item {
  margin-bottom:0
}
/deep/ .ivu-radio-large .ivu-radio-inner{
     width: 20px;
    height: 20px;
}
/deep/ .ivu-radio-inner:after{
    width: 12px;
    height: 12px;
    left: 3px;
    top: 3px;
}

 @import '../assets/css/common.css';
</style>
